package com.tang.controller;

import com.tang.pojo.Books;
import com.tang.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * @Author Tom
 * @ClassName QueryController
 * @Date 2022/1/1 17:52
 */
 @Controller
public class QueryController {
 @Autowired
 private BookService bookService;
//模糊查询传参
 @RequestMapping("/byName")
  public String QueryBookByName(String bookName, Model model, HttpServletRequest request){
   List<Books> books = bookService.queryBookByName(bookName);
   if (books==null){
       return "redirect:/index";
  }
    model.addAttribute("list",books);
      return "index";
  }
}
    